package com.itheima.mymap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/*
Map方法的使用
 */
public class Demo1 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        //添加
        map.put("郭靖","黄蓉");
        map.put("杨过","小龙女");
        map.put("张无忌","周芷若");
        map.put("张无忌","赵敏");
        //System.out.println(map);
        Set<String> keys = map.keySet();
        for (String key : keys) {
            String value = map.get(key);
            System.out.println(key+"..."+value);
        }
        System.out.println("------------------");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"..."+value);
        }
        //删除
        String s = map.remove("杨过");
        System.out.println(s);
        System.out.println(map);
        //清除
      //  map.clear();
        //获取长度
        int size = map.size();
        System.out.println("size = " + size);
        //集合是否为空
        boolean empty = map.isEmpty();
        System.out.println("empty = " + empty);
        //指定键
        boolean b = map.containsKey("尹志平");
        System.out.println("b = " + b);
        //指定值
        boolean b1 = map.containsValue("灭绝师太");
        System.out.println("b1 = " + b1);

    }
}
